//
//  ThirdMineViewController.m
//  marrymarry
//
//  Created by lsj on 16/9/12.
//  Copyright © 2016年 cf. All rights reserved.
//
static NSString * picCellID = @"MyPictureTableViewCell";
static NSString * takePicAndVideoCellID = @"OnlinePicViedoTableViewCell";
static NSString * infoOutCellID = @"InfoOutPutTableViewCell";
static NSString * YueBiCellID = @"YueBiTableViewCell";
static NSString * BaseInfoCellID = @"BaseInfoTableViewCell";
static NSString * CallCellID = @"CallTableViewCell";
#import "ThirdMineViewController.h"
#import "MyPictureTableViewCell.h"
#import "OnlinePicViedoTableViewCell.h"
#import "InfoOutPutTableViewCell.h"
#import "YueBiTableViewCell.h"
#import "BaseInfoTableViewCell.h"
#import "CallTableViewCell.h"
#import "MyHeadView.h"
#import "BiaoQianModel.h"
#import "InfoScrollBaseView.h"
#import "BasicInformationViewController.h"
#import "HeadImgViewController.h"
#import "AFNetworkReachabilityManager.h"
#import "OnlinePicAndVideoViewController.h"
#import "TopUpViewController.h"
#import "XPRZViewController.h"
#import "SingleCodeViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ThirdMineViewController ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
    BOOL isALLInfoFromNet;
    BOOL isAnimating;
    NSMutableArray *_ChosedArry;
    CGRect changeFrame;
    NSMutableArray *_addBiaoArry;
    NSMutableArray * _myNetPicArry;
    NSMutableArray * _myPicUrlArry;
    BOOL isreloadIMG;
    NSMutableDictionary * _myinfoDic;
    NSMutableDictionary * _otherInfoDic;
    NSDictionary * _userInfoDic;
    NSDictionary * _videoDic;
    NSDictionary * _photoDic;
    NSMutableArray * _onlineArry;
    BOOL islaodBaseInfo;
    BOOL isloadJinJiStatus;
    BOOL isLoadZeOu;
    BOOL isloadGuanNian;
    BOOL isloadQinMeSee;
    BOOL isloaddate;
    BOOL isloadMyAdvantage;
    BOOL isloadFriendLook;
    BOOL isloadCellPhone;
    BOOL isloadWeChat;
    BOOL isloadQQ;
    BOOL isloadZongHe;
    BOOL _isVIP_Custom;
    BOOL _isClickToWatch;
    BOOL _cutYB;
    BOOL _isClose;
    
    CGFloat _dateHeight;
    CGFloat _qinmiHeight;
    CGFloat _marryGuanNianHeight;
    CGFloat _zeOuHeight;
    CGFloat _JiBenHeight;
    CGFloat _JinJiHeight;
    
    int _clickTag;
    NSString *_canpay;
    
    
}
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (nonatomic,strong) MyHeadView * aView;

@property (weak, nonatomic) IBOutlet UIView *myAlertBaseView;
/** 提示框窗口 **/
@property (weak, nonatomic) IBOutlet UIView *myAlertInfoView;
/** 提示框八叉按钮 **/
@property (weak, nonatomic) IBOutlet UIButton *AlertCancelBtn;
/** 提示框信息 **/
@property (weak, nonatomic) IBOutlet UILabel *AlertLabel;
/** 提示框确定按钮 **/
@property (weak, nonatomic) IBOutlet UIButton *SureBtn;
/** 提示取消除按钮 **/
@property (weak, nonatomic) IBOutlet UIButton *AlertdeleBtn;


@property (nonatomic,strong) UIView * footView;

@property (nonatomic,strong) InfoScrollBaseView * BaseInfoView;
@property (weak, nonatomic) IBOutlet UIView *backGroundView;
@property (weak, nonatomic) IBOutlet UIView *myNavVeiw;
@property (nonatomic,strong) UIImageView *bgImgView;
@property (nonatomic, strong) PostImageView *postImageView;
@property (nonatomic, strong) NSArray<ZLSelectPhotoModel *> *lastSelectMoldels;
@property (nonatomic, strong) NSArray *arrDataSources;
@property (nonatomic,strong) NSArray * MyPicStrArry;

@property (strong,nonatomic) UIImageView * imgView;
@property (strong , nonatomic) NSArray * selectPicArry;
@property (strong,nonatomic) UIScrollView * imgScrollView;
@property (strong,nonatomic) CFinfoModel * model;
@property (strong,nonatomic) NSMutableDictionary * myBigDic;

@property (weak, nonatomic) IBOutlet UIButton *backBtn;
@property (weak, nonatomic) IBOutlet UIImageView *backImgView;
@property (weak, nonatomic) IBOutlet UIImageView *settingImgView;
@property (weak, nonatomic) IBOutlet UIButton *settimgBtn;

@property (strong, nonatomic) NSDictionary * myCheckDic ;

@property (strong,nonatomic) NSDictionary * myBaseDic ;

@end

@implementation ThirdMineViewController

-(NSDictionary*)myCheckDic
{
    if (!_myCheckDic) {
        _myCheckDic = [NSDictionary new];
    }
    return _myCheckDic;
}
-(NSDictionary*)myBaseDic
{
    if (!_myBaseDic) {
        _myBaseDic = [NSDictionary new];
    }
    return _myBaseDic;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.hidden = YES;
    [self setTrueALL];
    
    if (self.isGoToOther) {
        [self getMyInfoDicWithString:OTHER_BIGGEST_INFO_DIC];
        self.settimgBtn.hidden = YES;
        self.settingImgView.hidden = YES;
    }else{
     [self getMyInfoDicWithString:MY_BIGGEST_INFO_DIC];
        
    }
   
    [self.myTableView reloadData];
    
}

-(void)setTrueALL
{
    islaodBaseInfo = YES;
    isloadJinJiStatus = YES;
    isLoadZeOu = YES;
    isloadGuanNian = YES;
    isloadQinMeSee = YES;
    isloaddate = YES;
     isreloadIMG =YES;
    isloadMyAdvantage = YES;
    isloadFriendLook = YES;
    isloadCellPhone = YES;
    isloadWeChat = YES;
    isloadQQ = YES;
    isloadZongHe = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _isClose = YES;
    [self setTrueALL];
    self.model = [CFinfoModel new];
    _myNetPicArry = [NSMutableArray new];
    _myPicUrlArry = [NSMutableArray new];
    self.myBigDic = [NSDictionary new];
    _photoDic = [NSDictionary new];
    _videoDic = [NSDictionary new];
    _onlineArry = [NSMutableArray new];
    
    _myBaseDic =[Tools getValueFromNSUserDefaultsByKey:MY_BIGGEST_INFO_DIC];;
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor purpleColor];
    self.myTableView.backgroundColor = RGB(240, 239, 244);
    if (self.isGoToOther) {
        self.backBtn.hidden = NO;
        self.backImgView.hidden = NO;
        [self getMyInfoDicWithString:OTHER_BIGGEST_INFO_DIC];
        [self requestTheNetWith:nil andURL:TOPUP_URL andDic:@{@"userId":[Tools getValueFromNSUserDefaultsByKey:USERID]} andSignStr:ISVIPCUSTOM_SIGNSTR];
         self.myCheckDic = [Tools getValueFromNSUserDefaultsByKey:MY_BIGGEST_INFO_DIC];
        
    }else{
        self.title = @"我的";
        
        //    [self goCheckNetWork];
        ///拿到本地的myinfodic
        
        [self getMyInfoDicWithString:MY_BIGGEST_INFO_DIC];
    }
   [self setUI];
    
    _canpay = [Tools getValueFromNSUserDefaultsByKey:@"canpay"];
   
    
}


///返回上一层
- (IBAction)gobackVC:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)setUI
{
    ///设置头部
    [self setupTableHeaderView];
    ///设置尾部
    [self setupTableFootView];
    
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    ///注册照片的cell
    [self.myTableView registerNib:[UINib nibWithNibName:@"MyPictureTableViewCell" bundle:nil] forCellReuseIdentifier:picCellID];
    [self.myTableView registerNib:[UINib nibWithNibName:@"OnlinePicViedoTableViewCell" bundle:nil] forCellReuseIdentifier:takePicAndVideoCellID];
    [self.myTableView registerNib:[UINib nibWithNibName:infoOutCellID bundle:nil] forCellReuseIdentifier:infoOutCellID];
    [self.myTableView registerNib:[UINib nibWithNibName:YueBiCellID bundle:nil] forCellReuseIdentifier:YueBiCellID];
    [self.myTableView registerNib:[UINib nibWithNibName:BaseInfoCellID bundle:nil] forCellReuseIdentifier:BaseInfoCellID];
     [self.myTableView registerNib:[UINib nibWithNibName:CallCellID bundle:nil] forCellReuseIdentifier:CallCellID];
}


-(void)goCheckNetWork
{
    // 1.获得网络监控的管理者
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    // 2.设置网络状态改变后的处理
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        // 当网络状态改变了, 就会调用这个block
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
                // 未知网络
                NSLog(@"未知网络");

                break;
            case AFNetworkReachabilityStatusNotReachable:
                // 没有网络(断网)
                ///拿到本地的myinfodic
//                [self getMyInfoDic];
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                // 手机自带网络
                NSLog(@"手机自带网络");

                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                // WIFI
                NSLog(@"WIFI");
  
                break;
        }
    }]; 
    
    // 3.开始监控 
    [manager startMonitoring];
}
#pragma mark -------- 拿到本地的myinfodic
-(void)getMyInfoDicWithString:(NSString * )DicKey
{
    [_myPicUrlArry removeAllObjects];
    isALLInfoFromNet =YES;
   _myinfoDic = [NSMutableDictionary new];
    NSMutableDictionary * infoDic = [Tools getValueFromNSUserDefaultsByKey:MY_INFO_DIC];
    _myinfoDic = [NSMutableDictionary dictionaryWithDictionary:infoDic];
    NSLog(@"%@",_myinfoDic);
    _otherInfoDic = [NSMutableDictionary new];
    NSMutableDictionary * otherDic = [Tools getValueFromNSUserDefaultsByKey:OTHER_INFO_DIC];
    _otherInfoDic = [NSMutableDictionary dictionaryWithDictionary:otherDic];
    self.myBigDic = [Tools getValueFromNSUserDefaultsByKey:DicKey];
    
    
    [self.model saveTheUserDescDic:self.myBigDic[@"userDesc"]];
    if ([self.myBigDic[@"photoAlbum"] isKindOfClass:[NSArray class]]) {
        _myNetPicArry = self.myBigDic[@"photoAlbum"];
    if ([_myNetPicArry[0] isKindOfClass:[NSDictionary class]]) {
        for (NSDictionary *picDic in _myNetPicArry) {
            [_myPicUrlArry addObject:picDic[@"photoAlbum"]];
        }
    }else{
        if (_myNetPicArry.count>0) {
        for (int i= 0; i<_myNetPicArry.count; i++) {
            [_myPicUrlArry addObject:_myNetPicArry[i]];
        }
        }
    }
    if (_myNetPicArry) {
        self.MyPicStrArry = _myPicUrlArry ;
    }
    }
    [self setTrueALL];
    [self setupTableHeaderView];
    [self.myTableView reloadData];
}

- (IBAction)settingBtnSelect:(id)sender {
    UIStoryboard * headSB = [UIStoryboard storyboardWithName:@"HeadImgViewController" bundle:nil];
    HeadImgViewController * headVC = [headSB instantiateViewControllerWithIdentifier:@"HeadImgViewController"];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:headVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}



-(void)setupTableFootView
{
    self.footView = [UIView new];
    self.footView.frame = CGRectMake(0,0,ScreenWidth,60);
    self.footView.backgroundColor = RGB(240, 239, 244);
    self.myTableView.tableFooterView = self.footView;
}

#pragma mark ----------点击了设置
- (IBAction)ChoseBackImg:(UIButton *)sender {
    NSLog(@"点击了 封面选择");
}

///选择存储img的数组
-(NSArray *)selectPicArry
{
    if (!_selectPicArry) {
        _selectPicArry = [NSArray new];
    }
    return _selectPicArry;
}

- (void)setupTableHeaderView {
    if (isALLInfoFromNet) {
        [self.aView removeFromSuperview];
    }
    self.aView = [[[NSBundle mainBundle] loadNibNamed:@"MyHeadView" owner:self options:nil] lastObject];
    self.aView.frame = CGRectMake(0, 0,self.view.frame.size.width, 420);
    /** 如果是访问别人的主页 **/
    if (self.isGoToOther) {
        self.aView.AddSignBtn.hidden = YES;
        self.aView.pencilImgView.hidden = YES;
    }else{
        self.aView.AddSignBtn.hidden = NO;
        self.aView.pencilImgView.hidden = NO ;
    }
   
    [self.aView.AddSignBtn addTarget:self action:@selector(addBQ) forControlEvents:UIControlEventTouchUpInside];
    [self goSetMyHeadImgView];
    
}


#pragma mark --------- 设置我的头部窗口数据
-(void)goSetMyHeadImgView
{

//    NSString * imgStr;
    NSString * myDesStr;
    NSDictionary * AddBiaoQianDic = [NSDictionary new];
    _addBiaoArry= [NSMutableArray new];
    _userInfoDic = [NSDictionary new];
    isALLInfoFromNet = YES;
    if (isALLInfoFromNet) {
        NSDictionary * idcardDic = [NSDictionary new];
        idcardDic = self.myBigDic[@"idcard"];
        
        if ([idcardDic[@"facePhoto"] isKindOfClass:CFNULL]) {
            [self.aView.headerContentView setImage:[UIImage imageNamed:@"0.jpg"]];
        }else{
        [self.aView.headerContentView setImageWithURL:[NSURL URLWithString:idcardDic[@"facePhoto"]]];
        }
        if (self.isGoToOther) {
            [self.aView.giftCountBtn setTitle:[NSString stringWithFormat:@"%d人对Ta送礼物",[self.myBigDic[@"giftcount"] intValue]] forState:UIControlStateNormal];
            [self.aView.heartCountBtn setTitle:[NSString stringWithFormat:@"%d人对Ta心动",[self.myBigDic[@"likecount"] intValue]] forState:UIControlStateNormal];
        }else
        {
            [self.aView.giftCountBtn setTitle:[NSString stringWithFormat:@"%d人对Wo送礼物",[self.myBigDic[@"giftcount"] intValue]] forState:UIControlStateNormal];
            [self.aView.heartCountBtn setTitle:[NSString stringWithFormat:@"%d人对Wo心动",[self.myBigDic[@"likecount"] intValue]] forState:UIControlStateNormal];
        }
        
        if (![self.myBigDic[@"userDesc"] isKindOfClass:CFNULL]) {
            
            if ([self.model readTheUserDescDic] && !self.isGoToOther) {
                AddBiaoQianDic = [self.model readTheUserDescDic];
            }else{
            AddBiaoQianDic = self.myBigDic[@"userDesc"];
            }
            myDesStr = [AddBiaoQianDic[@"role"] stringByAppendingFormat:@",%@,%@",AddBiaoQianDic[@"nature"],AddBiaoQianDic[@"hobby"]];
            _addBiaoArry =[[NSMutableArray alloc]initWithArray:[myDesStr componentsSeparatedByString:@","]];
            if ([_addBiaoArry containsObject:@""]) {
                [_addBiaoArry removeObject:@""];
            }
            [self.aView reloadTheHeadInfoViewWithArry:_addBiaoArry];
        }
        _userInfoDic = self.myBigDic[@"user"];
        self.aView.nameLabel.text = _userInfoDic[@"userName"];
        
    }else{
//        imgStr = [Tools getValueFromNSUserDefaultsByKey:PERSON_PIC];
//        NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//        NSString * documentsDirectory = [paths objectAtIndex:0];
//        self.aView.headerContentView.image = [UIImage imageWithContentsOfFile:[documentsDirectory stringByAppendingPathComponent:imgStr]];
//        
//        AddBiaoQianDic = [Tools getValueFromNSUserDefaultsByKey:@"addarr"];
//        if (AddBiaoQianDic!=nil) {
//            
//            _addBiaoArry = AddBiaoQianDic[@"addArr"];
//            [self.aView reloadTheHeadInfoViewWithArry:_addBiaoArry];
//        }
//        self.aView.nameLabel.text = _myinfoDic[NICHEN_KEY];
    }

     self.myTableView.tableHeaderView = self.aView;
}

- (UIImage *)getSnapshotImage {
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)), NO, 1);
    [self.view drawViewHierarchyInRect:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) afterScreenUpdates:NO];
    UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return snapshot;
}
#pragma mark -------- 点击了添加标签
-(void)addBQ
{
    NSDictionary * AddBiaoQianDic = [NSDictionary new];
    AddBiaoQianDic = [Tools getValueFromNSUserDefaultsByKey:@"addarr"];
    _addBiaoArry = AddBiaoQianDic[@"addArr"];
    
    self.tabBarController.tabBar.hidden = YES;
    CGRect frame = self.view.frame;
    frame.size.height = self.view.frame.size.height+64;
    self.view.frame = frame;
    
    self.bgImgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    self.bgImgView.image = [self getSnapshotImage];;
    [self.view addSubview:self.bgImgView];
    UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bgImgView.frame.size.width, self.bgImgView.frame.size.height)];
    toolbar.barStyle = UIBarStyleBlackTranslucent;
    [self.bgImgView addSubview:toolbar];
    self.BaseInfoView = [[[NSBundle mainBundle]loadNibNamed:@"InfoScrollBaseView" owner:self options:nil]lastObject];
    self.BaseInfoView.frame = CGRectMake(8,self.view.frame.size.height/2-183,self.view.frame.size.width-16, 283);
    [self.view addSubview:self.BaseInfoView];
    [self.BaseInfoView.cancelBtn addTarget:self action:@selector(cancelTheView) forControlEvents:UIControlEventTouchUpInside];
    [self.BaseInfoView getSaveDicWithBlock:^(NSDictionary *saveDic , NSString * lookstr , NSString * natureStr,NSString *intereStr) {
 
//        NSLog(@"%@",saveDic);
        _ChosedArry = saveDic[@"addArr"];
        
        NSMutableDictionary * myUserDes = [[NSMutableDictionary alloc]initWithDictionary:self.myBigDic[@"userDesc"]];
        [myUserDes setObject:lookstr forKey:@"role"];
        [myUserDes setObject:natureStr forKey:@"character"];
        [myUserDes setObject:intereStr forKey:@"hobby"];

        [self.model saveTheUserDescDic:myUserDes];
        NSMutableDictionary * BigDescDic = [NSMutableDictionary dictionaryWithDictionary:self.myBigDic];
        
        [BigDescDic setObject:myUserDes forKey:@"userDesc"];

        [self.model saveTheBiggestDic:BigDescDic];

        
        
        NSDictionary * dic =[NSDictionary new];
        dic=@{@"id":[Tools getValueFromNSUserDefaultsByKey:USERID],@"sessionkey":[Tools getValueFromNSUserDefaultsByKey:USERSESSION],@"role":lookstr,@"character":natureStr,@"hobby":intereStr};
        [[LJFNetworkingManager shareManager] POST:BIAOQIAN_URL parameters:dic success:^(id returnData, int code, NSString *msg) {
          
            
            [self.aView reloadTheHeadInfoViewWithArry:_ChosedArry];
            [self cancelTheView];
        } failure:^(NSError *error) {
            NSLog(@"失败了");
        } showHUD:self.view];
      
    }];
    self.myTableView.userInteractionEnabled = NO;
    BiaoQianModel * biaoQModel = [BiaoQianModel new];
   NSDictionary * dic = [biaoQModel goBackDicWithSex:[Tools getValueFromNSUserDefaultsByKey:@"Mysex"]];
    [self.BaseInfoView reloadTheBaseViewWithDic:dic andFenKongArry:_addBiaoArry];
    
    if (AddBiaoQianDic!=nil) {
    [self.BaseInfoView readTheToolsToLoadViewsWith:_addBiaoArry];
    }
    
}

-(void)reloadTheBaseInfoViewWitharr:(NSMutableArray*)choseArr
{
    int hangNum = 0;
    if (choseArr.count%4== 0) {
        hangNum =(int)choseArr.count/4;
    }else
    {
        hangNum = (int)choseArr.count/4+1;
    }
    NSLog(@"%d",hangNum);
    changeFrame =CGRectMake(8,420-hangNum*20, ScreenWidth-16,125+hangNum*20);
    self.aView.headInfoView.frame =changeFrame;
    [self.myTableView reloadData];
    [self cancelTheView];
}




#pragma mark -------点击了在线拍摄照片
-(void)takeOnlinePic:(UIButton *)PicBtn
{
    UIStoryboard * bascInfoSB =[UIStoryboard storyboardWithName:@"OnlinePicAndVideoViewController" bundle:nil];
    OnlinePicAndVideoViewController * OnlineVC = [bascInfoSB instantiateViewControllerWithIdentifier:@"OnlinePicAndVideoViewController"];
    if (self.isGoToOther) {
        OnlineVC.isOtherWatch = YES;
    }else{
        OnlineVC.isOtherWatch = NO;
    }
    OnlineVC.isVideoType =NO;
    OnlineVC.otherID = self.otherID;
       self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:OnlineVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}
#pragma mark -------点击了在线拍摄视频
-(void)takeOnlineVideo:(UIButton *)VideoBtn
{
    UIStoryboard * bascInfoSB =[UIStoryboard storyboardWithName:@"OnlinePicAndVideoViewController" bundle:nil];
    OnlinePicAndVideoViewController * OnlineVC = [bascInfoSB instantiateViewControllerWithIdentifier:@"OnlinePicAndVideoViewController"];
    if (self.isGoToOther) {
        OnlineVC.isOtherWatch = YES;
    }else{
        OnlineVC.isOtherWatch = NO;
    }
    OnlineVC.isVideoType = YES;
    OnlineVC.otherID = self.otherID;
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:OnlineVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}



#pragma mark ------- 点击了取消
-(void)cancelTheView
{
    CGRect frame = self.view.frame;
    frame.size.height = self.view.frame.size.height-64;
    self.view.frame = frame;
    self.tabBarController.tabBar.hidden = NO;
    [self.bgImgView removeFromSuperview];
    [self.BaseInfoView removeFromSuperview];
    self.myTableView.userInteractionEnabled = YES;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [self.aView scrollDidScroll:scrollView];
    if (scrollView.tag ==500) {
        self.myNavVeiw.backgroundColor = [UIColor colorWithRed:120/255.0 green:120/255.0 blue:122/255.0 alpha:scrollView.contentOffset.y/300];
    }
}



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 9;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 4) {
        return 3;
    }else if (section == 5)
    {
        return 3;
    }else if (section == 8)
    {
        return 3;
    }else{
        return 1;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        MyPictureTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:picCellID];
        if (!cell) {
            cell = [[MyPictureTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:picCellID];
        }
        if (isreloadIMG) {
//            NSDictionary * dic = [NSDictionary new];
            for (UIImageView * myOldImgView in cell.myPicScrollView.subviews ) {
                [myOldImgView removeFromSuperview];
            }
            if (isALLInfoFromNet) {
                for (int i = 0; i<self.MyPicStrArry.count; i++) {
                    cell.imgView = [UIImageView new];
                    cell.imgView.frame = CGRectMake(0+140*i+2*i,0,140,140);
                    [cell.imgView setImageWithURL:[NSURL URLWithString:self.MyPicStrArry[i]]];
                    cell.imgView.tag = i;
                    if (self.isGoToOther) {
                        [cell.myBigScrollView addSubview:cell.imgView];
                    }else{
                    [ cell.myPicScrollView addSubview:cell.imgView];
                    }
                    cell.imgView.userInteractionEnabled = YES;
                    cell.imgView.contentMode = UIViewContentModeScaleToFill;
                    cell.imgView.clipsToBounds = YES;
                    CFUITapGestureRecognizer * imgbigTap = [[CFUITapGestureRecognizer alloc]initWithTarget:self action:@selector(imgbig:)];
                    imgbigTap.tapImgView = cell.imgView;
                    [cell.imgView addGestureRecognizer:imgbigTap];
                }
            }
           
            
            cell.picNumLabel.text =[NSString stringWithFormat:@"照片(%d)",(int)self.MyPicStrArry.count];
            if (self.isGoToOther) {
              cell.myBigScrollView.contentSize = CGSizeMake(self.MyPicStrArry.count * (140+2), 0);
                cell.myBigScrollView.tag =200;
                cell.myBigScrollView.hidden = NO;
            }else{
                cell.myPicScrollView.contentSize = CGSizeMake(self.MyPicStrArry.count * (140+2), 0);
                cell.myPicScrollView.tag =200;
            }
            
            cell.selectionStyle = UITableViewCellAccessoryNone;
            cell.FirstImgView.userInteractionEnabled =YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addphoto)];
            [cell.FirstImgView addGestureRecognizer:tap];
            cell.backgroundColor = RGB(245, 245, 247);
        }
        isreloadIMG = NO;
        return cell;
    }
    else if (indexPath.section == 1)
    {  OnlinePicViedoTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:takePicAndVideoCellID];
        if (!cell) {
            cell = [[OnlinePicViedoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:takePicAndVideoCellID];
            
        }
        if (self.isGoToOther) {
            cell.OtherWatchPicLabel.text = @"查看在线认证照片";
            cell.OtherWatchVideoLabel.text = @"查看在线认证视频";
        }else{
        }
        
        _onlineArry =[[NSMutableArray alloc]initWithArray:self.myBigDic[@"onlineMedia"]];
        if ([_onlineArry isKindOfClass:[NSArray class]]) {
            
            for (int i = 0; i<_onlineArry.count; i++) {
                if ([_onlineArry[i][@"type"] isEqualToString:@"image"]) {
                    _photoDic =self.myBigDic[@"onlineMedia"][i];
                }else if([_onlineArry[i][@"type"] isEqualToString:@"video"])
                {
                    _videoDic = self.myBigDic[@"onlineMedia"][i];
                }
                
            }
    
        }
        if (_photoDic[@"media"]) {
            [cell.photoBackImgView setImageWithURL:[NSURL URLWithString:_photoDic[@"media"]]];
            cell.photoBackImgView.alpha = 0.5;
        }else if (_videoDic[@"media"])
        {
            cell.videoBackImgView.image = [self thumbnailImageForVideo:[NSURL URLWithString:_videoDic[@"media"]]];
            cell.videoBackImgView.alpha = 0.5;
        }
        
        [cell.takePicBtn addTarget:self action:@selector(takeOnlinePic:) forControlEvents:UIControlEventTouchUpInside];
        [cell.takeVideoBtn addTarget:self action:@selector(takeOnlineVideo:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
        
    }else if (indexPath.section == 2)
    {
        InfoOutPutTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:infoOutCellID];
        if(!cell)
        {
            cell = [[InfoOutPutTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:infoOutCellID];
        }
        cell.clickImgView.userInteractionEnabled = YES;
        CFUITapGestureRecognizer * upTap = [[CFUITapGestureRecognizer alloc]initWithTarget:self action:@selector(reloadTheCurrentView)];
        [cell.clickImgView addGestureRecognizer:upTap];
        if (_isClose) {
            [cell.clickImgView setImage:[UIImage imageNamed:@"upBtn.png"]];
            cell.collageLabel.hidden =YES;
            cell.skillLabel.hidden =YES;
            cell.cardNumberLabel.hidden=YES;
            cell.cardAcceptTime.hidden= YES;
            cell.studyAcceptLabel.hidden = YES;
            cell.clickToWatch.hidden = YES;
        }else{
            [cell.clickImgView setImage:[UIImage imageNamed:@"downBtn.png"]];
            cell.clickToWatch.hidden = NO;
            cell.collageLabel.hidden =NO;
            cell.skillLabel.hidden =NO;
            cell.cardNumberLabel.hidden=NO;
            cell.cardAcceptTime.hidden= NO;
            cell.studyAcceptLabel.hidden = NO;
        }
        if (isloadZongHe) {
            isloadZongHe = NO;
            [cell reloadWithDic:self.myBigDic andIsOhterLook:self.isGoToOther andIsClickBtn:_isClickToWatch];
        }
        if (self.isGoToOther) {
            cell.clickToWatch.tag = RZINFO_BTN_TAG;
            [cell.clickToWatch addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
        }else{
//            cell.clickToWatch.hidden = YES;
            [cell.clickToWatch addTarget:self action:@selector(goRZVC) forControlEvents:UIControlEventTouchUpInside];
        }
        return cell;
    }else if (indexPath.section == 3)
    {
        
        YueBiTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:YueBiCellID];
        if(!cell)
        {
            cell = [[YueBiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:YueBiCellID];
        }
        if (self.isGoToOther) {
            cell.priceLabel.text = @"";
            cell.topView.hidden = NO;
            [cell.goInviatBtn addTarget:self action:@selector(goInviate) forControlEvents:UIControlEventTouchUpInside];
        }else
        {
            [cell.myInviatBtn addTarget:self action:@selector(goInviate) forControlEvents:UIControlEventTouchUpInside];
            cell.priceLabel.text = [NSString stringWithFormat:@"%@约币",self.myBigDic[@"yuebi"]];
        }
        if ([_canpay isEqualToString:@"0"]) {
            cell.hidden = YES;
        }else
        {
            cell.hidden = NO;
        }
        return cell;
    }
    ///基本资料、经济状况、择偶标准
    else if (indexPath.section == 4)
    {
        BaseInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:BaseInfoCellID];
        if (!cell) {
            cell = [[BaseInfoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BaseInfoCellID];
        }
        cell.grayLineLabel.hidden = NO;
        if (indexPath.row == 0 && indexPath.section == 4) {
            cell.bigTitleLabel.text = @"基本资料";
            if (islaodBaseInfo) {
                if (isALLInfoFromNet) {
                     _myinfoDic = self.myBigDic[@"user"];
                }
                _JiBenHeight = [cell loadJiBenInfoWithDic:_myinfoDic];
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
                islaodBaseInfo = NO;
            }
            cell.watchBtn.tag = BASEINFO_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }else if (indexPath.row == 1)
        {
            
            cell.bigTitleLabel.text = @"经济状况";
            if (isloadJinJiStatus) {
                if (isALLInfoFromNet) {
                    _myinfoDic = self.myBigDic[@"money"];
                }
             _JinJiHeight =  [cell loadJinJiStatusWithDic:_myinfoDic andCarStatusDic:self.myBigDic[@"car"] andHouseStatusDic:self.myBigDic[@"house"]];
                
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
                isloadJinJiStatus = NO;
            }
            cell.watchBtn.tag = MONEY_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }
        else if (indexPath.row ==2 )
        {
            cell.bigTitleLabel.text = @"择偶标准";
            cell.grayLineLabel.hidden = YES;
            if (isLoadZeOu) {
                if (isALLInfoFromNet) {
                    _otherInfoDic = self.myBigDic[@"mateStandard"];
                    if ([_myinfoDic isKindOfClass:[NSNull class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }
                }
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
              _zeOuHeight = [cell loadZeOuInfoWithDic:_otherInfoDic];
                isLoadZeOu = NO;
            }
            cell.watchBtn.tag = ZEOU_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }else
        {
          return cell;
        }
    }
    ///婚姻观念、亲密视觉、约会交往
    else if (indexPath.section == 5)
    {
        BaseInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:BaseInfoCellID];
        if (!cell) {
            cell = [[BaseInfoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BaseInfoCellID];
        }
        cell.grayLineLabel.hidden = NO;
        if (indexPath.row == 0) {
            cell.bigTitleLabel.text = @"婚姻观念";
            if (isloadGuanNian) {
                if (isALLInfoFromNet) {
                    if ([self.myBigDic[MY_HUNYINGUANNIAN_DIC] isKindOfClass:[NSString class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }else{
                    _otherInfoDic = self.myBigDic[@"marriageConcept"];
                    }
                    if ([_myinfoDic isKindOfClass:[NSNull class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }
                }
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
                 _marryGuanNianHeight = [cell loadHunYinGuanNianDic:_otherInfoDic];
                isloadGuanNian = NO;
            }
            cell.watchBtn.tag = MARRYGUAN_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }else if (indexPath.row == 1)
        {
            cell.bigTitleLabel.text = @"亲密视角";
            if (isloadQinMeSee) {
                if (isALLInfoFromNet) {
                    if ([self.myBigDic[MY_QINGMI_DIC] isKindOfClass:[NSString class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }else{
                        _otherInfoDic = self.myBigDic[MY_QINGMI_DIC];
                    }

                    if ([_myinfoDic isKindOfClass:[NSNull class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }
                }
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
                _qinmiHeight = [cell loadQinMiShiJiaoDic:_otherInfoDic andIndexPath:indexPath];
                isloadQinMeSee = NO;
            }
            cell.watchBtn.tag = QINMI_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }
        else if (indexPath.row ==2 )
        {
            cell.bigTitleLabel.text = @"约会交往";
            cell.grayLineLabel.hidden = YES;
            if (isloaddate) {
                if (isALLInfoFromNet) {
//                    _otherInfoDic = self.myBigDic[@"dating"];
                    if ([_myinfoDic isKindOfClass:[NSNull class]]) {
                        _otherInfoDic = [[NSMutableDictionary alloc]initWithDictionary:@{}];
                    }
                }
                if (self.isGoToOther) {
                    cell.editPencilImgView.hidden = YES;
                    cell.watchBtn.hidden = NO;
                }else{
                    cell.editPencilImgView.hidden = NO;
                    cell.watchBtn.hidden = YES;
                }
                _dateHeight = [cell loadQinMiShiJiaoDic:_otherInfoDic andIndexPath:indexPath];
                isloaddate = NO;
            }
            cell.watchBtn.tag = DATE_BTN_TAG;
            [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }else
        {
            return cell;
        }
    }
    ///我的优势
    else if (indexPath.section == 6)
    {
        BaseInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:BaseInfoCellID];
        if (!cell) {
            cell = [[BaseInfoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BaseInfoCellID];
        }
        if (isloadMyAdvantage) {
            cell.bigTitleLabel.text=@"我的优势";
            cell.grayLineLabel.hidden = YES;
            cell.myAdvantageLabel.hidden = NO;
            
            if (_isVIP_Custom || self.isGoToOther == NO) {
                cell.myAdvantageLabel.text =self.myBigDic[@"user"][MY_ADVANTAGE_KEY];
            }else{
                cell.myAdvantageLabel.text = @"";
            }
            
            isloadMyAdvantage = NO;
            if (self.isGoToOther) {
                cell.editPencilImgView.hidden = YES;
                cell.watchBtn.hidden = NO;
            }else{
                cell.editPencilImgView.hidden = NO;
                cell.watchBtn.hidden = YES;
            }
        }
        cell.watchBtn.tag = MYADVANTAGES_BTN_TAG;
        [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    ///朋友看我
    else if (indexPath.section == 7)
    {
        BaseInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:BaseInfoCellID];
        if (!cell) {
            cell = [[BaseInfoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BaseInfoCellID];
        }
        if (isloadFriendLook) {
            isloadFriendLook = NO;
            cell.bigTitleLabel.text=@"朋友看我";
            cell.grayLineLabel.hidden = YES;
            cell.myAdvantageLabel.hidden = NO;
            cell.myAdvantageLabel.text =self.myBigDic[@"user"][FRIEND_LOOKME_KEY];
            if (self.isGoToOther) {
                cell.editPencilImgView.hidden = YES;
                cell.watchBtn.hidden = NO;
            }else{
                cell.editPencilImgView.hidden = NO;
                cell.watchBtn.hidden = YES;
            }
        }
        cell.watchBtn.tag = FRIENDLOOKME_BTN_TAG;
        [cell.watchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    ///手机、微信
    else if (indexPath.section == 8)
    {
        CallTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CallCellID];
        if (!cell) {
            cell = [[CallTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CallCellID];
        }
        cell.grayLineLabel.hidden = NO;
        if (self.isGoToOther) {
            cell.pencilImgView.hidden = YES;
            cell.goWatchBtn.hidden = NO;
        }else{
            cell.pencilImgView.hidden = NO;
            cell.goWatchBtn.hidden = YES;
        }
        if (indexPath.row == 0 && indexPath.section == 8) {
            if (isloadCellPhone) {
                if (_isVIP_Custom || self.isGoToOther == NO) {
                    cell.myInfoLabel.text =self.myBigDic[CONTANCT_DIC_KEY][CELLPHONE_KEY];
                }else{
                    cell.myInfoLabel.text = @"";
                }
                
                isloadCellPhone = NO;
                cell.myTitleLabel.text=@"手机";
                cell.myInfoLabel.hidden = NO;
                
            }
            cell.goWatchBtn.tag = MOBILE_BTN_TAG;
            [cell.goWatchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }else if (indexPath.row ==1 && indexPath.section == 8)
        {
            if (isloadWeChat) {
                isloadWeChat = NO;
                if (_isVIP_Custom || self.isGoToOther == NO) {
                    cell.myInfoLabel.text =self.myBigDic[CONTANCT_DIC_KEY][WECHAT_KEY];
                }else{
                    cell.myInfoLabel.text = @"";
                }
                
                cell.myTitleLabel.text=@"微信";
                cell.myInfoLabel.hidden = NO;
                

            }
            cell.goWatchBtn.tag = WECHAT_BTN_TAG;
            [cell.goWatchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return  cell;
        }
        else if (indexPath.row ==2 && indexPath.section == 8)
        {
            if (isloadQQ) {
                isloadQQ = NO;
                if (_isVIP_Custom || self.isGoToOther == NO) {
                   cell.myInfoLabel.text =self.myBigDic[CONTANCT_DIC_KEY][QQ_KEY];
                }else{
                    cell.myInfoLabel.text = @"";
                }
                
                cell.myTitleLabel.text=@"QQ";
                cell.grayLineLabel.hidden = YES;
                cell.myInfoLabel.hidden = NO;
            }
            cell.goWatchBtn.tag = QQ_BTN_TAG;
            [cell.goWatchBtn addTarget:self action:@selector(goWatch:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }
        else
        {
            return cell;
        }
        
    }
    else
    {
        OnlinePicViedoTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:picCellID];
        if (!cell) {
            cell = [[OnlinePicViedoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:takePicAndVideoCellID];
            
        }
        return cell;
    }
   
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 4|| section == 5||section == 6||section==7||section == 8) {
        return 10;
    }else{
        return 0;
    }
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section ==0) {
        return 185;
    }else if (indexPath.section == 1)
    {
        return 100;
    }else if (indexPath.section ==2)
    {
        
        if (_isClose) {
            return 60;
        }else{
        return 130;
        }
        
    }
    else if (indexPath.section ==3)
    {
        if ([_canpay isEqualToString:@"0"]) {
            return 1;
        }else{
        return 60;
        }
    }else
    {
        return 70;
    }
   
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (_isVIP_Custom||self.isGoToOther == NO) {
        UIStoryboard * bascInfoSB =[UIStoryboard storyboardWithName:@"BasicInformationViewController" bundle:nil];
        BasicInformationViewController * bascInfoVC = [bascInfoSB instantiateViewControllerWithIdentifier:@"BasicInformationViewController"];
        if (self.isGoToOther) {
            bascInfoVC.isGoToOther = YES;
            bascInfoVC.saveBtn.hidden = YES;
        }else{
            bascInfoVC.isGoToOther = NO;
            bascInfoVC.saveBtn.hidden = NO;
        }
        if (indexPath.section == 2) {
            [self goRZVC];
            return;
        }
        else if (indexPath.section == 3)
        {
            NSLog(@"");
            [self gotoTopUpYB];
            return;
        }
        else if (indexPath.section == 4) {
            if (indexPath.row == 0) {
                bascInfoVC.isGoToBaseInforTable = YES;
            }else if (indexPath.row == 1)
            {
                bascInfoVC.isGoToJinJiInforTable = YES;
            }else if (indexPath.row == 2)
            {
                bascInfoVC.isGoToZeOu = YES;
            }
        }else if (indexPath.section == 5)
        {
            if (indexPath.row == 0) {
                bascInfoVC.isGoToHunYinGuanNian = YES;
            }else if (indexPath.row == 1)
            {
                bascInfoVC.isGoToQinMiShiJiao = YES;
            }else if (indexPath.row == 2)
            {
                bascInfoVC.isGoToDate = YES;
            }
        }else if (indexPath.section == 6)
        {
            bascInfoVC.isGoToMyAdvantage = YES;
        }else if (indexPath.section == 7)
        {
            bascInfoVC.isGoToFriendLookMe = YES;
        }else if (indexPath.section == 8)
        {
            if (indexPath.row == 0) {
                bascInfoVC.isGoToContancet = YES;
            }else if (indexPath.row == 1)
            {
                bascInfoVC.isGoToWeChat = YES;
            }else if (indexPath.row == 2)
            {
                bascInfoVC.isGoToQQ = YES;
            }
        }
        
        
        self.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:bascInfoVC animated:YES];
        self.hidesBottomBarWhenPushed = NO;
        

    }else{
       
//        _clickTag = (int)WatchBtn.tag;
        if (indexPath.section == 2)
        {
            _clickTag = (int)RZINFO_BTN_TAG;
            if ([_myBaseDic[@"user"][@"school"] isEqualToString:@""]) {
                [self showAlertWithSignStr:@"InforLose"];
                 return;
            }else{
                [self SuccessGotoWatch:YES];
                return;
            }
           
        }
        else if (indexPath.section == 3)
        {
            NSLog(@"");
            [self gotoTopUpYB];
            return;
        }
        else if (indexPath.section == 4)
        {
            if (indexPath.row == 0) {
                _clickTag=(int)BASEINFO_BTN_TAG;
                
            }else if (indexPath.row == 1)
            {
                _clickTag=(int)MONEY_BTN_TAG;
                
            }else if (indexPath.row == 2)
            {
                _clickTag=(int)ZEOU_BTN_TAG;
            }
        }
        else if (indexPath.section == 5)
        {
            if (indexPath.row == 0) {
                _clickTag=(int)MARRYGUAN_BTN_TAG;
            }else if (indexPath.row == 1)
            {
                _clickTag=(int)QINMI_BTN_TAG;
            }else if (indexPath.row == 2)
            {
                _clickTag=(int)DATE_BTN_TAG;
            }
        }
        else if (indexPath.section == 6)
        {
            _clickTag=(int)MYADVANTAGES_BTN_TAG;
        }
        else if (indexPath.section == 7)
        {
            _clickTag=(int)FRIENDLOOKME_BTN_TAG;
        }
        else if (indexPath.section == 8)
        {
            if (indexPath.row == 0) {
                _clickTag=(int)MOBILE_BTN_TAG;
            }else if (indexPath.row == 1)
            {
                _clickTag=(int)WECHAT_BTN_TAG;
            }else if (indexPath.row == 2)
            {
                _clickTag=(int)QQ_BTN_TAG;
            }
        }
        
        UIButton * btn = [[UIButton alloc]init];
        btn.tag = _clickTag;
       
        self.backGroundView.hidden = NO;
        [self goWatch:btn];
    }

    
    
}


-(void)reloadTheCurrentView
{
    _isClose =!_isClose;
    isloadZongHe = YES;
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:2];
    [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];

}

-(void)goRZVC
{
    self.backGroundView.hidden = YES;
    UIStoryboard *xpSb = [UIStoryboard storyboardWithName:@"XPRZViewController" bundle:nil];
    XPRZViewController * xpvc = [xpSb instantiateViewControllerWithIdentifier:@"XPRZViewController"];
    if (self.isGoToOther) {
        xpvc.other_idStr = self.otherID;
        NSLog(@"xpvc.other_idStr =======  %@/n/n/n/n/n/n",xpvc.other_idStr);
    }else{
        xpvc.other_idStr =nil;
    }
   
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:xpvc animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}




//获取视频封面，本地视频，网络视频都可以用

- (UIImage*)thumbnailImageForVideo:(NSURL *)videoURL {
    
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
    
    AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    
    gen.appliesPreferredTrackTransform = YES;
    
    CMTime time = CMTimeMakeWithSeconds(2.0, 600);
    
    NSError *error = nil;
    
    CMTime actualTime;
    
    CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
    
    UIImage *thumbImg = [[UIImage alloc] initWithCGImage:image];
    
    return thumbImg;
    
}

#pragma mark ---------点击跳转到单身码
-(void)goInviate
{
    UIStoryboard * SingleInfoSB =[UIStoryboard storyboardWithName:@"SingleCodeViewController" bundle:nil];
    SingleCodeViewController * SingleInfoVC = [SingleInfoSB instantiateViewControllerWithIdentifier:@"SingleCodeViewController"];
    SingleInfoVC.mySingleNumStr = _myBaseDic[@"user"][@"singleNumber"];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:SingleInfoVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;

}


#pragma mark -----------点击去查看
-(void)goWatch:(UIButton *)WatchBtn
{
   
        _clickTag = (int)WatchBtn.tag;
    if (_isVIP_Custom) {
        [self SuccessGotoWatch:YES];
    }else{
    self.myCheckDic = [Tools getValueFromNSUserDefaultsByKey:MY_BIGGEST_INFO_DIC];
    self.backGroundView.hidden = NO;
        switch (_clickTag) {
            case RZINFO_BTN_TAG:
                self.backGroundView.hidden = YES;
                WatchBtn.hidden = YES;
                NSLog(@"点击了查看认证信息");
                if ([_myBaseDic[@"user"][@"school"] isEqualToString:@""]) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                        _isClickToWatch = YES;
                        isloadZongHe = YES;
                        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:2];
                        [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
                }
                break;
            case BASEINFO_BTN_TAG:
                NSLog(@"点击了查看资料");
                if ([self.myCheckDic[@"user"][LOVE_HISTORY_KEY] isEqualToString:@""] ) {
                     [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];

                }
                break;
            case MONEY_BTN_TAG:
                NSLog(@"点击了查看资产");
                if ([self.myCheckDic[@"money"][CAR_PRICE_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                    
                }
                break;
            case ZEOU_BTN_TAG:
                NSLog(@"点击了查看择偶标准");
                if ([self.myCheckDic[@"mateStandard"][MARRY_STATUS] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                    
                }
                break;
            case MARRYGUAN_BTN_TAG:
                NSLog(@"点击了查看婚姻观念");
                if ([self.myCheckDic[@"marriageConcept"][MARRY_WITH_CHILD_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                    
                }
                break;
            case QINMI_BTN_TAG:
                NSLog(@"点击了查看亲密视角");
                if ([self.myCheckDic[MY_QINGMI_DIC][THINK_YOUR_SEX_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                    
                }
                break;
            case DATE_BTN_TAG:
                NSLog(@"点击了查看约会交往");
                if ([self.myCheckDic[MY_QINGMI_DIC][FIRST_MEET_WHOPAY_KEY]isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                    
                }
                break;
            case MYADVANTAGES_BTN_TAG:
                NSLog(@"点击了查看我的优势");
                if ([self.myCheckDic[@"user"][MY_ADVANTAGE_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                        [self SuccessGotoWatch:YES];
                }
                break;
            case FRIENDLOOKME_BTN_TAG:
                NSLog(@"点击了查看朋友看我");
                if ( [self.myCheckDic[@"user"][FRIEND_LOOKME_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                }
                break;
            case MOBILE_BTN_TAG:
                NSLog(@"点击了查看手机号");
                if ([self.myCheckDic[CONTANCT_DIC_KEY][CELLPHONE_KEY] isEqualToString:@""] ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                        [self SuccessGotoWatch:YES];
                    }
                break;
            case WECHAT_BTN_TAG:
                NSLog(@"点击了查看微信号");
                if ([self.myCheckDic[CONTANCT_DIC_KEY][WECHAT_KEY] isEqualToString:@""]  ) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                    [self SuccessGotoWatch:YES];
                }
                break;
            case QQ_BTN_TAG:
                NSLog(@"点击了查看qq号");
                if ([self.myCheckDic[CONTANCT_DIC_KEY][QQ_KEY] isEqualToString:@""]) {
                    [self showAlertWithSignStr:@"InforLose"];
                }else{
                        [self SuccessGotoWatch:YES];
                }
                break;
                
            default:
                break;
        }
        
        
    }
    
}

-(void)showAlertWithSignStr:(NSString *)signStr
{
    self.backGroundView.hidden = NO;
    if ([signStr isEqualToString:@"payOneYB"]) {
        /** 显示是否支付一约币 **/
        self.AlertLabel.text =@"浏览该信息会扣除您账户1约币";
        [self.SureBtn addTarget:self action:@selector(gotoPayOneYB) forControlEvents:UIControlEventTouchUpInside];
    }else if([signStr isEqualToString:@"YBNotEnough"])
    {
        /** 显示约币不足 是否去充值 **/
        self.AlertLabel.text =@"浏览该信息会扣除您账户1约币,您的约币不足,请去充值";
        [self.SureBtn addTarget:self action:@selector(gotoTopUpYB) forControlEvents:UIControlEventTouchUpInside];
        
    }else if ([signStr isEqualToString:@"InforLose"])
    {
        /** 信息不完整 **/
        self.AlertLabel.text =@"基于对等原则,你需要先完善自己的资料才能查看TA的资料";
        
        [self.SureBtn addTarget:self action:@selector(SuccessGotoWatch:) forControlEvents:UIControlEventTouchUpInside];
    }
    [self.AlertdeleBtn addTarget:self action:@selector(cancelTheAlertView) forControlEvents:UIControlEventTouchUpInside];
    [self.AlertCancelBtn addTarget:self action:@selector(cancelTheAlertView) forControlEvents:UIControlEventTouchUpInside];
    self.myAlertBaseView.layer.cornerRadius = 7;
    self.SureBtn.layer.cornerRadius = 7;
    self.AlertdeleBtn.layer.cornerRadius = 7;
    self.myAlertInfoView.layer.cornerRadius = 7;
}


/** 去充值 **/
-(void)gotoTopUpYB
{
    
    UIStoryboard * TopUpSB = [UIStoryboard storyboardWithName:@"TopUpViewController" bundle:nil];
    TopUpViewController * TopUpVC  = [TopUpSB instantiateViewControllerWithIdentifier:@"TopUpViewController"];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:TopUpVC animated:YES];
}



/** 付款1约币 **/
-(void)gotoPayOneYB
{
    [self requestTheNetWith:nil andURL:CUTYB_URL andDic:@{@"userId":[Tools getValueFromNSUserDefaultsByKey:USERID],@"money":@"1.00"} andSignStr:CUTMYYB_SIGNSTR];
    
}

/** 取消 **/
-(void)cancelTheAlertView
{
    self.backGroundView.hidden = YES;

}


/** 1约币扣除成功之后的跳转 **/
-(void)SuccessGotoWatch:(BOOL)isLookOther
{
    self.backGroundView.hidden = YES;
    UIStoryboard * bascInfoSB =[UIStoryboard storyboardWithName:@"BasicInformationViewController" bundle:nil];
    BasicInformationViewController * bascInfoVC = [bascInfoSB instantiateViewControllerWithIdentifier:@"BasicInformationViewController"];
    switch (_clickTag) {
        case RZINFO_BTN_TAG:
            NSLog(@"点击了查看认证信息");
            [self goRZVC];
            return;
            break;
        case BASEINFO_BTN_TAG:
            NSLog(@"点击了查看资料");
            bascInfoVC.isGoToBaseInforTable = YES;
            break;
        case MONEY_BTN_TAG:
            NSLog(@"点击了查看资产");
            bascInfoVC.isGoToJinJiInforTable = YES;
            break;
        case ZEOU_BTN_TAG:
            NSLog(@"点击了查看择偶标准");
            bascInfoVC.isGoToZeOu = YES;
            break;
        case MARRYGUAN_BTN_TAG:
            NSLog(@"点击了查看婚姻观念");
            bascInfoVC.isGoToHunYinGuanNian = YES;
            break;
        case QINMI_BTN_TAG:
            NSLog(@"点击了查看亲密视角");
            bascInfoVC.isGoToQinMiShiJiao = YES;
            break;
        case DATE_BTN_TAG:
            NSLog(@"点击了查看约会交往");
            bascInfoVC.isGoToDate = YES;
            break;
        case MYADVANTAGES_BTN_TAG:
            NSLog(@"点击了查看我的优势");
            bascInfoVC.isGoToMyAdvantage = YES;
            break;
        case FRIENDLOOKME_BTN_TAG:
            NSLog(@"点击了查看朋友看我");
            bascInfoVC.isGoToFriendLookMe = YES;
            break;
        case MOBILE_BTN_TAG:
            NSLog(@"点击了查看手机号");
             bascInfoVC.isGoToContancet = YES;
            break;
        case WECHAT_BTN_TAG:
            NSLog(@"点击了查看微信号");
            bascInfoVC.isGoToWeChat = YES;
            break;
        case QQ_BTN_TAG:
            NSLog(@"点击了查看qq号");
            bascInfoVC.isGoToQQ = YES;
            break;
            
        default:
            break;
    }
    bascInfoVC.isVip = _isVIP_Custom;
    bascInfoVC.isGoToOther = isLookOther;
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:bascInfoVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;


}



///添加照片
-(void)addphoto
{

    self.imgScrollView = [self.view viewWithTag:200];
    ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init];
    //设置照片最大选择数
    actionSheet.maxSelectCount = 5;
    //设置照片最大预览数
    actionSheet.maxPreviewCount = 20;
    weakify(self);
    [actionSheet showWithSender:self animate:YES lastSelectPhotoModels:self.lastSelectMoldels completion:^(NSArray<UIImage *> * _Nonnull selectPhotos, NSArray<ZLSelectPhotoModel *> * _Nonnull selectPhotoModels) {
        strongify(weakSelf);
        strongSelf.arrDataSources = selectPhotos;
        strongSelf.lastSelectMoldels = selectPhotoModels;
        NSLog(@"%@", selectPhotos);
        self.selectPicArry = strongSelf.arrDataSources;
        
        
        [self requestTheNetWith:self.selectPicArry andURL:MYALBUM_URL andDic:@{@"sessionkey":[Tools getValueFromNSUserDefaultsByKey:USERSESSION],@"id":[Tools getValueFromNSUserDefaultsByKey:USERID]} andSignStr:PIC_SIGNSTR];
    }];

}
-(void)imgbig:(CFUITapGestureRecognizer*)imgTap
{
    [ZLShowBigImage showBigImage:imgTap.tapImgView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}







#pragma mark --------------网络请求
-(void)requestTheNetWith:(NSArray *)myRequestArry andURL:(NSString *)myurl andDic:(NSDictionary *)myDic andSignStr:(NSString *)signStr;
{
    if (myRequestArry.count>0) {
        [[LJFNetworkingManager shareManager] POST:myurl upLoadImages:myRequestArry parameters:myDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",msg);
            isALLInfoFromNet =YES;
            NSArray * myReturnArr = [NSArray arrayWithArray:returnData];
            for (int i =0; i<myReturnArr.count; i++) {
                [_myPicUrlArry addObject:myReturnArr[i]];
            }
            self.MyPicStrArry = [NSArray arrayWithArray:_myPicUrlArry];
            NSMutableDictionary * myNewDic =[NSMutableDictionary dictionaryWithDictionary:self.myBigDic];
            [myNewDic setObject:self.MyPicStrArry forKey:@"photoAlbum"];

            [self.model saveTheBiggestDic:myNewDic];
//              [self saveMyPhoto];
            
            
            isreloadIMG = YES;
            NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
            [self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        } failure:^(NSError *error) {
            NSLog(@"失败");
            isALLInfoFromNet = NO;
        } showHUD:nil];
        
    }else
    {
        [[LJFNetworkingManager shareManager] POST:myurl parameters:myDic success:^(id returnData, int code, NSString *msg) {
            NSLog(@"%@",msg);
            if ([signStr isEqualToString:ISVIPCUSTOM_SIGNSTR]) {
                NSLog(@"returnData ============ %@\n\n",returnData);
                if (code == 1) {
                    if ([returnData[@"vip"] intValue] == 1) {
                        _isVIP_Custom = NO;
                    }else{
                        _isVIP_Custom = YES;
                    }
                }else{
                    
                }
                
            }
            else if ([signStr isEqualToString:CUTMYYB_SIGNSTR])
            {
                if (code == 1) {
                    _cutYB = YES;
                    self.backGroundView.hidden= YES;
                    [self SuccessGotoWatch:YES];
                }else{
                    _cutYB = NO;
                    [self showAlertWithSignStr:@"YBNotEnough"];
                }
                
            }
//            isALLInfoFromNet =YES;
//            NSLog(@"returnData =-===== %@",returnData);
//            self.myBigDic = [self.model sendUseDicWithDic:returnData];
//            NSLog(@"self.myBigDic === %@",self.myBigDic);
           
        } failure:^(NSError *error) {
            NSLog(@"%@",error);
            if ([signStr isEqualToString:CUTMYYB_SIGNSTR])
            {
            _cutYB = NO;
            self.backGroundView.hidden= YES;
            [self showAlertWithSignStr:@"YBNotEnough"];
            }

        } showHUD:self.view];
        
    }
   
    
}




#pragma mark ------ 如果上传图片成功 就把图片存到沙盒
-(void)saveMyPhoto
{
    NSMutableDictionary *  savePicDic = [Tools getValueFromNSUserDefaultsByKey:PICIMG_ARR];
    self.MyPicStrArry = savePicDic[PICIMG_ARR];
    NSMutableArray * fininalArr = [NSMutableArray new];
    //取到沙盒路径
    NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString * documentsDirectory = [paths objectAtIndex:0];
    for (int i =0; i<self.selectPicArry.count; i++) {
        NSData *data2 = UIImageJPEGRepresentation(self.selectPicArry[i], 1.0);
        //    [data1 writeToFile:[homePath stringByAppendingString:@"/Documents/left1.jpg"] atomically:YES];
        NSString * savePicStr = [NSString stringWithFormat:@"Pesronal%d.jpg",i+(int)self.MyPicStrArry.count];
        [data2 writeToFile:[documentsDirectory stringByAppendingPathComponent:savePicStr] atomically:NO];
        [fininalArr addObject:savePicStr];
    }
    NSMutableDictionary *newSavePicDic = [NSMutableDictionary new];
    [fininalArr addObjectsFromArray:self.MyPicStrArry];
    self.MyPicStrArry = [NSArray arrayWithArray:fininalArr];
    [newSavePicDic setObject:self.MyPicStrArry forKey:PICIMG_ARR];
    NSLog(@"%@",fininalArr);
    NSLog(@"%lu",fininalArr.count);
    [Tools syncNSUserDeafaultsByKey:PICIMG_ARR withValue:(NSDictionary *)newSavePicDic];
    self.imgScrollView.contentSize = CGSizeMake(fininalArr.count * (140+2), 0);
    isreloadIMG = YES;
    
    [self.myTableView reloadData];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
